﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using Model.Domain_Model;
using Model.DTO;

namespace Repository.DatabaseType
{
    public class SqlServer2008:IDb
    {
        private readonly string connectionString = @"Server=oem-komputer\centralpoint;Database=WektaDev;User Id=wekta;Password=wekta;Connection Timeout=5";
        private SqlConnection connection = null;
        public ClientTable Clients = null;

        public SqlServer2008()
        {
            CreateConnection();
            Clients = new ClientTable(connection,this);
        }

        internal void CreateConnection()
        {
            connection = new SqlConnection(connectionString);
        }

        internal void OpenConnection()
        {
            if (connection.State == ConnectionState.Closed)
                connection.Open();
        }

        internal void CloseConnection()
        {
            connection.Close();
        }

        ClientTable IDb.Clients
        {
            get { return new ClientTable(connection, this); }
        }


        RoadTable IDb.Roads
        {
            get { return new RoadTable(connection, this); }
        }
    }
}
